<?php session_start();?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="maintenancePagesCSS.css" />
        <title>Edit Product</title>
    <style type="text/css">

    </style></head>
    <body>
    <div align="center">
      <table width="1000" height="655" border="0" background="images/background.jpg">
        <tr>
          <th height="526" scope="col"><p>
            <?php

print("

<html>
    <head>
        <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
        <title></title>
    </head>
    <body>
        <center>
");

include "Datasource.php";
include "ProductDetails.php";
include "ProductDetailsDao.php";

//create connection to database
$connection = new Datasource("localhost","theanykey","root","");
//print("DS Good"); //Used for testing

//create dao object to interact with database
$productDetailsDao = new ProductDetailsDao();
//print("DAO Good"); //Used for testing

//create new customer valueObject and populate with data from post
$part = new ProductDetails();
$part->setAll("", $_POST["Manufacturer"],
    $_POST["ModelNo"], $_POST["SerialNo"],
    $_POST["CompanyPrice"], $_POST["CustomerPrice"],
    $_POST["TechNotes"]);

//print("Part Good"); //Used for testing
//send valueObject to dao so that it can be added to database
if($productDetailsDao->create($connection, $part))
{

//Use db count method to return the valueObject from db with PK
//still dont know if this will always work
//$part = $productDetailsDao->getObject($connection, $productDetailsDao->countAll($connection));



//print($customer->toString()); //Used for testing


?>
          </p>
            <p><img src="images/TitleProductInformation.gif" alt="Product Information" width="514" height="67"></p>
            <table border="0" class="SelectTable">
              <tbody>
                <tr>
                  <td>Manufacturer:</td>
                  <td><?php print($part->getManufacturer());  ?></td>
                </tr>
                <tr>
                  <td>Model Number:</td>
                  <td><?php print($part->getModelNo());  ?></td>
                </tr>
                <tr>
                  <td>Serial Number:</td>
                  <td><?php print($part->getSerialNo());  ?></td>
                </tr>
                <tr>
                  <td>Company Price:</td>
                  <td><?php print($part->getCompanyPrice());  ?></td>
                </tr>
                <tr>
                  <td>Customer Price:</td>
                  <td><?php print($part->getCustomerPrice());  ?></td>
                </tr>
                <tr>
                  <td>Tech Notes:</td>
                  <td><?php print($part->getTechNotes());  ?></td>
                </tr>
                <tr>
                  <td colspan=2> <div align="center"><U>Part successfully added to database.</U> </div></td>
                </tr>
              </tbody>
            </table>
            <?php
            }//end if
            else
            {
                ?>
            <font style="color: Red">Please go back and try again.</font> <br/>
            <br/>
            <?php
            }

            ?>
            <br>
            <br>
            <script src="links.js" language="javascript" type="text/javascript"></script>
            <script type="text/javascript">
            writeProductLinks("addPart.php", "Add Another Part");
                </script>
            </center></th>
        </tr>
        <tr>
          <th height="123" scope="col">&nbsp;</th>
        </tr>
      </table>
      <p>&nbsp;</p>
    </div>
    </body>
</html>
